package com.lib.base.base

import android.content.Context
import androidx.multidex.MultiDexApplication
import com.alibaba.android.arouter.launcher.ARouter
import com.lib.base.BuildConfig
import timber.log.Timber

open class BaseApplication : MultiDexApplication() {

    companion object {
        var appContext: BaseApplication? = null
        /**Application 初始化是否完成*/
        var buildFinish: Boolean = false
    }


    override fun onCreate() {
        super.onCreate()
        appContext = this

        /**  阿里路由---2019-06-18 */
        if (BuildConfig.DEBUG) {
            ARouter.openLog()
            ARouter.openDebug()

            /**  Timber 日志---2019-06-18 */
            Timber.plant(Timber.DebugTree())
        }
        ARouter.init(this)
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        buildFinish = true
    }

    override fun onTerminate() {
        super.onTerminate()
        ARouter.getInstance().destroy()
    }
}